<?php
	include_once '../models/Model.php';
	$model=new Model();
	$roomName=$_POST['roomName'];
	$roomCategory=$_POST['roomCategory'];
	$roomCost=$_POST['roomCost'];
	$roomSeatCount=$_POST['roomSeatCount'];
	// room da ton tai
	if($model->searchRoomByName($roomName)->getRoomId()!=null||$roomName==''||$roomCost==''||$roomSeatCount=='')
		echo -1;		
	else
	{	
		$room=new Room($roomId,$roomCategory,$roomName,$roomCost,$roomSeatCount);	
	// error add	
		if($model->addRoom($room)==-1)
			echo 0;
		// success add
		else {
			$date = date("Y-m-d H:i:s");
			$log = $date."---Event---".$roomName."---AddRoom\n";
			$path="../log/log.txt";
			$file=fopen($path, "a");
			$write=fwrite($file,$log);
			fclose($file);
			echo 1;
		}
		
	}
	//var_dump($_GET['roomName']);
	//echo -1;
?>